/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.ui.rich.learn.learn_view.dialog;

import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JPanel;


/**
*
* @author Moreira, Renata & Pitangueira, Roque
* @since May 2005
*/

public final class NewMatrixViewTableDialog {
	private String title;
	private int nLines;
	private int nColumns;
	private JButton[][] cells;



	/**
	 * Constructor method.
	 *
	 * @param title   a dialog title.
	 * @see javax.swing
	 */
	public NewMatrixViewTableDialog(String title, int nLines, int nColumns, JButton[][] cells) {
		if(title == null || nLines <= 0 || nColumns <= 0){
		System.out.println("Erron in InpOutTableDialog constructor"
					+"\nTable Title = "+title
					+"\nTable Numero de Linhas = "+nLines
					+"\nTable Numero de Colunas = "+nColumns);
		System.exit(0);
		}
		this.title = title;
		this.nLines = nLines;
		this.nColumns = nColumns;
		this.cells = cells;
	}//End of OutputTableDialog

	
	public JPanel getMatrixPanel( ) {
		if(cells ==null){
			System.out.println("Erron in addOutputTable method"
						+"\nCells = "+cells);
				System.exit(0);
		}	
		
		JPanel tablePaneMae = new JPanel();
		tablePaneMae.setLayout( new GridBagLayout());

		JPanel tablePane = new JPanel();
		tablePane.setLayout(new GridLayout(nLines,nColumns,0,0));
		
		for(int i=0; i < nLines; i++)
		for(int j=0; j < nColumns; j++)
		{
			Dimension d = new Dimension();
			d.width=110;
			d.height=25;
			cells[i][j].setPreferredSize(d);
			tablePane.add(cells[i][j]);
		}
		tablePaneMae.add(tablePane);
		return tablePaneMae;
	} //End of addOutputTable
    
    /**
     * @return Returns the nLines.
     */
    public int getNLines() {
        return nLines;
    }
    /**
     * @param lines The nLines to set.
     */
    public void setNLines(int lines) {
        nLines = lines;
    }
    /**
     * @return Returns the title.
     */
    public String getTitle() {
        return title;
    }
    /**
     * @param title The title to set.
     */
    public void setTitle(String title) {
        this.title = title;
    }
}// End of class

//==== End of File
